package cn.ym.ymcc.doc;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 文档映射
 */
@Document(indexName = "course",type = "_doc")
@Data
public class CourseDoc {
    @Id  //把存储数据的id值作为文档id
    private Long id;

    //课程名
    @Field(
            type = FieldType.Text,  //字段是字符串，并且要分词
            analyzer = "ik_max_word", //存储数据的时候要细粒度分词
            searchAnalyzer = "ik_max_word")//搜索数据的时候，也要细粒度分词
    private String name;

    //适用人群
    @Field(type = FieldType.Keyword)
    private String forUser;

    //课程类型id
    @Field(type = FieldType.Long)
    private Long courseTypeId;

    //等级名
    @Field(type = FieldType.Keyword)
    private String gradeName;

    //课程封面
    @Field(type = FieldType.Keyword)
    private String pic;



    //上线时间
    @Field(type = FieldType.Date)
    private Date onlineTime;

    //老师名
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String teacherNames;


    //-------------------------------------课程营销表
    /**
     * 收费规则：，收费1免费，2收费
     */
    @Field(type = FieldType.Keyword)
    private String chargeName;

    //课程折扣价格
    @Field(type = FieldType.Double)
    private BigDecimal price;
    /**
     * 原价
     */
    @Field(type = FieldType.Double)
    private BigDecimal priceOld;


    //--------------------------------课程汇总表
    /**
     * 销量
     */
    @Field(type = FieldType.Integer)
    private Integer saleCount;
    /**
     * 浏览量
     */
    @Field(type = FieldType.Integer)
    private Integer viewCount;
    /**
     * 评论数
     */
    @Field(type = FieldType.Integer)
    private Integer commentCount;
}
